#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define OJ_TEST 0
#define LOCAL_TEST 0

#define M 121

static int max(int a, int b){ return a>b?a:b; }
static int min(int a, int b) { return a<b?a:b; }
static char map[M][M];
static int flip[M][M];
static int d8x[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
static int d8y[8] = { -1, -1, -1, 0, 0, 1, 1 ,1};

static void solve(void){
	int cs;
	int i,j,k ,  m, n, y ,x, cnt;
	cs=0;
	while(scanf("%d%d", &n, &m)){
		if(n==0) break;
		if(cs) printf("\n");
		for(i=0; i<n; ++i){
			scanf("%s", map[i]);
		}
		printf("Field #%d:\n", ++cs);
		for(i=0; i<n; ++i){
			for(j=0; j<m; ++j){
				if(map[i][j]=='.'){
					cnt = 0;
					for(k=0; k<8; ++k){
						y = i+d8y[k]; x = j+d8x[k];
						if(y>=0 && y<n && x>=0 && x<m  && map[y][x]=='*'){
							++cnt;
						}
					}
					flip[i][j] = cnt;
					printf("%d", cnt);
				}else{
					flip[i][j] = -1;
					printf("*");
				}
			}
			printf("\n");
		}
	}
}
#if OJ_TEST
	int main(int ac, char *av[]){
		solve();
		return 0;
	}
#elif  LOCAL_TEST
	void run(void){
		solve();
	}

#else

#endif
